
import * as PIXI from 'pixi.js';
import Text from 'components/text';
import Image from 'components/image';
const { Container } = PIXI;

export default class UnOpenPrompt {
  constructor({parent, CONST, text}) {

    this.parent = parent;
    this.CONST = CONST;

    this.container = new Container();

    this.container.y = CONST.top;

    setTimeout(() => {
      this.parent.container.removeChild(this.container);
    }, CONST.disappearTime);

    this._renderBg(text);
    this._renderText(text);
  }

  _renderBg = () => {
    const { view } = window.CFG;
    const { width, height, bgSrc, } = this.CONST;
    let bg = new Image({
      src: bgSrc,
      top: 0,
      left: (view.width - width) / 2,
      width: width,
      height: height,
    });

    this.container.addChild(bg);
  };

  _renderText = (text) => {
    const { view } = window.CFG;
    const { fontSize, lineHeight, top, height } = this.CONST;

    let promptText = new Text({
      value: text,
      lineHeight,
      fontSize,
    });

    promptText.x = (view.width - promptText.width) / 2;
    promptText.y = top + (height - promptText.height) / 2;

    this.container.addChild(promptText);

  };

}
